package org.litemall.netty.nettyDoman;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

/**
 * @Author Lizr
 * @Description
 * @CreateTime 2021-10-30 上午 10:04
 **/
@Data
public class Result {
    private int code;
    private String msg;
    private Object data;

    private Result(int code, String msg, Object data){
        this.code = code;
        this.msg = msg;
        this.data = data;

    }

    public static Result success(Object data){
        return new Result(0, "操作成功",data);
    }

    public static Result error(String msg, Object data){
        return new Result(500, msg,  data);
    }
    public static Result error(String msg){
        return new Result(500, msg, null);
    }
    @Override
    public String toString(){
        return JSONObject.toJSONString(this);
    }
}
